package Week4.J0510;

import java.util.Scanner;

public class 打怪 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();

        while (t-- != 0) {
            int h = scanner.nextInt();
            int a = scanner.nextInt();

            int H = scanner.nextInt();
            int A = scanner.nextInt();

            if (a >= H) System.out.println(-1);
            else {
                int m = H / a + (H % a != 0 ? 1 : 0); //怪物能抗几下
                int n = m - 1; // 杀死一只怪物的时候，玩家被攻击几下
                int x = n * A; // 杀死一只怪物的时候，玩家掉的血量
                int ret = h / x - (h % x == 0 ? 1 : 0);
                System.out.println(ret);
            }
        }
    }
}
